home *** CD-ROM | disk | FTP | other *** search
- // Bits.h
-
- #ifndef Bits_h
- #define Bits_h
-
- #ifndef Integers_h
- #include "Integers.h"
- #endif
-
- class Bits
- {
- private:
- static const uint8 count[ maxuint8 + 1 ];
- static const uint8 firstZero[ maxuint8 + 1 ];
- static const uint8 lastZero[ maxuint8 + 1 ];
- static const uint8 reverse[ maxuint8 + 1 ];
-
- public:
- static uint32 Count( uint8 n ) { return count[n]; }
- static uint32 Count( uint16 n );
- static uint32 Count( uint32 n );
-
- static uint32 FirstZero( uint8 n ) { return firstZero[n]; }
- static uint32 FirstZero( uint16 n );
- static uint32 FirstZero( uint32 n );
-
- static uint32 LastZero( uint8 n ) { return lastZero[n]; }
- static uint32 LastZero( uint16 n );
- static uint32 LastZero( uint32 n );
-
- static uint32 FirstOne( uint8 n ) { return FirstZero( uint8(~n) ); }
- static uint32 FirstOne( uint16 n ) { return FirstZero( uint16(~n) ); }
- static uint32 FirstOne( uint32 n ) { return FirstZero( uint32(~n) ); }
-
- static uint32 LastOne( uint8 n ) { return LastZero( uint8(~n) ); }
- static uint32 LastOne( uint16 n ) { return LastZero( uint16(~n) ); }
- static uint32 LastOne( uint32 n ) { return LastZero( uint32(~n) ); }
-
- static uint8 Reverse( uint8 n ) { return reverse[n]; }
- static uint16 Reverse( uint16 n );
- static uint32 Reverse( uint32 n );
- };
-
- #endif
-